<?php

class Log
{
    private $filepath="./";

    function __construct($path=__DIR__."/log/")
    {
        $this->filepath = $path;
        if (!is_dir($path)) {
            mkdir($path, 0777, true);
        }
    }

    function write($str)
    {
        $filename = date("Y-m-d").".log";
        $myfile = fopen($this->filepath.$filename, "a");
        $writestr = sprintf("[%s]%s\n", date("H:i:s"), $str);
        fwrite($myfile, $writestr);
        fclose($myfile);
    }
}

?>